package com.yegrina.member.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.yegrina.member.domain.Member;

public class MemberValidator implements Validator {

	public boolean supports(Class<?> clazz) {
		return Member.class.isAssignableFrom(clazz);
	}

	public void loginValidate(Object target, Errors errors){
		Member command = (Member) target;
		//System.out.println(command);
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"userid", "error.required.member.userid");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"userpasswd", "error.required.member.userpasswd");
	}
	
	
	public void validate(Object target, Errors errors) {
		Member command = (Member) target;
		//System.out.println(command);
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"userid", "error.required.member.userid");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"userpasswd", "error.required.member.userpasswd");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"username", "error.required.member.username");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"email", "error.required.member.email");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"sex", "error.required.member.sex");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"birthday", "error.required.member.birthday");
		
		
		 
	}
}
